<include file="Common:minheader" />
<!-- /. NAV SIDE  -->
<style>
	.hg{
		height:30px;
		line-height:30px;
	}
	.title{
		margin-top:30px;
	}
</style>
<form class="layui-form" action="" id="purchaseform">
	<input type="hidden" name="id" value="{$goodsInfo.id}">
	<div class="layui-form-item">
		<table class="layui-table itemlist" id="productInfos" style="white-space:nowrap;">
			<thead><tr><th>产品名</th><th>规格</th><th>库存</th><th>冻结库存</th></tr></thead>
			<volist name="goodsList" id="vo">
				<tbody>
				    <tr>
				        <td>
				            <input type="hidden" name="goods_list_id[]" value="{$vo.id}"/>{$goodsInfo.goods_title}
				        </td>
				        <td>
				            {$vo.goods_spec}
				        </td>
				        <td>
				            <input type="text" name="stocks[]" placeholder="输入库存数" autocomplete="off" class="layui-input itemnums" lay-verify="required" value="{$vo.stocks}"/>
				        </td>
				        <td>
				            {$vo.freez}
				        </td>
				    </tr>
				</tbody>
			</volist>
		</table>
	</div>
	<div class="layui-form-item" style="padding-bottom:50px">
		<div class="layui-input-block">
		  <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
		  <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</div>
</form>
<script type="text/javascript">
	layui.use('form', function(){
	  var form = layui.form;
	  //监听提交
	  form.on('submit(formDemo)', function(data){
			var cont = $('#purchaseform').serialize();
			$.ajax({
				url:"{:U('Goods/updateGoodStocks')}",
				type:'post',
				dataType:'json',
				data:cont,
				success:function(data){
					if(data.code==0){
						layer.alert(data.message);
					}else{
						layer.alert(data.message, function(index){
							//do something
							window.parent.location.reload();
							var index = parent.layer.getFrameIndex(window.name); 
							parent.layer.close(index);
						});
					}
				}
			});
			//layer.msg(JSON.stringify(data.field));
			return false;
	  });
	});
</script>
<!-- /. PAGE INNER  -->
<include file="Common:footer" />